﻿///////////////////////////////////////////////////////////////
// This is generated code. 
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 3.1
// Code is generated on: Wednesday, June 29, 2011 7:51:30 PM
// Code is generated using templates: SD.TemplateBindings.SharedTemplates.NET20
// Templates vendor: Solutions Design.
// Templates version: 
//////////////////////////////////////////////////////////////
using System;
using System.Collections;
using System.Collections.Generic;
using MECPSDB;
using MECPSDB.FactoryClasses;
using MECPSDB.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

namespace MECPSDB.RelationClasses
{
	/// <summary>Implements the relations factory for the entity: Material. </summary>
	public partial class MaterialRelations
	{
		/// <summary>CTor</summary>
		public MaterialRelations()
		{
		}

		/// <summary>Gets all relations of the MaterialEntity as a list of IEntityRelation objects.</summary>
		/// <returns>a list of IEntityRelation objects</returns>
		public virtual List<IEntityRelation> GetAllRelations()
		{
			List<IEntityRelation> toReturn = new List<IEntityRelation>();
			toReturn.Add(this.MatimgEntityUsingMatCode);
			toReturn.Add(this.MatbrandEntityUsingBrandCodeFk);
			toReturn.Add(this.MatgroupEntityUsingMatGrpCodeFk);
			toReturn.Add(this.MatumEntityUsingUmCodeFk);
			return toReturn;
		}

		#region Class Property Declarations


		/// <summary>Returns a new IEntityRelation object, between MaterialEntity and MatimgEntity over the 1:1 relation they have, using the relation between the fields:
		/// Material.MaterialCode - Matimg.MatCode
		/// </summary>
		public virtual IEntityRelation MatimgEntityUsingMatCode
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToOne, "Matimg", true);

				relation.AddEntityFieldPair(MaterialFields.MaterialCode, MatimgFields.MatCode);



				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("MaterialEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("MatimgEntity", false);
				return relation;
			}
		}

		/// <summary>Returns a new IEntityRelation object, between MaterialEntity and MatbrandEntity over the m:1 relation they have, using the relation between the fields:
		/// Material.BrandCodeFk - Matbrand.BrandCode
		/// </summary>
		public virtual IEntityRelation MatbrandEntityUsingBrandCodeFk
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "Matbrand", false);
				relation.AddEntityFieldPair(MatbrandFields.BrandCode, MaterialFields.BrandCodeFk);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("MatbrandEntity", false);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("MaterialEntity", true);
				return relation;
			}
		}
		/// <summary>Returns a new IEntityRelation object, between MaterialEntity and MatgroupEntity over the m:1 relation they have, using the relation between the fields:
		/// Material.MatGrpCodeFk - Matgroup.MatGrpCode
		/// </summary>
		public virtual IEntityRelation MatgroupEntityUsingMatGrpCodeFk
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "Matgroup", false);
				relation.AddEntityFieldPair(MatgroupFields.MatGrpCode, MaterialFields.MatGrpCodeFk);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("MatgroupEntity", false);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("MaterialEntity", true);
				return relation;
			}
		}
		/// <summary>Returns a new IEntityRelation object, between MaterialEntity and MatumEntity over the m:1 relation they have, using the relation between the fields:
		/// Material.UmCodeFk - Matum.UomCode
		/// </summary>
		public virtual IEntityRelation MatumEntityUsingUmCodeFk
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "Matum", false);
				relation.AddEntityFieldPair(MatumFields.UomCode, MaterialFields.UmCodeFk);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("MatumEntity", false);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("MaterialEntity", true);
				return relation;
			}
		}
		/// <summary>stub, not used in this entity, only for TargetPerEntity entities.</summary>
		public virtual IEntityRelation GetSubTypeRelation(string subTypeEntityName) { return null; }
		/// <summary>stub, not used in this entity, only for TargetPerEntity entities.</summary>
		public virtual IEntityRelation GetSuperTypeRelation() { return null;}
		#endregion

		#region Included Code

		#endregion
	}
	
	/// <summary>Static class which is used for providing relationship instances which are re-used internally for syncing</summary>
	internal static class StaticMaterialRelations
	{
		internal static readonly IEntityRelation MatimgEntityUsingMatCodeStatic = new MaterialRelations().MatimgEntityUsingMatCode;
		internal static readonly IEntityRelation MatbrandEntityUsingBrandCodeFkStatic = new MaterialRelations().MatbrandEntityUsingBrandCodeFk;
		internal static readonly IEntityRelation MatgroupEntityUsingMatGrpCodeFkStatic = new MaterialRelations().MatgroupEntityUsingMatGrpCodeFk;
		internal static readonly IEntityRelation MatumEntityUsingUmCodeFkStatic = new MaterialRelations().MatumEntityUsingUmCodeFk;

		/// <summary>CTor</summary>
		static StaticMaterialRelations()
		{
		}
	}
}
